Post

Replies

Boosts

Views

Activity

App sometimes crashes after tapping notification in the Notification Center.
So my app creates user notifications. Sometimes when I tap one of these notification to open the app, it crashes. It happens seemingly randomly and is not easy to reproduce. My app's UNUserNotificationCenterDelegate does something like this (shortened to keep the post concise): -(void)userNotificationCenter:(UNUserNotificationCenter*)center didReceiveNotificationResponse:(UNNotificationResponse*)response          withCompletionHandler:(void(^)(void))completionHandler { if (![response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier])     { //only care about the default action...return out otherwise.         completionHandler();         return;     } completionHandler(); UNNotificationRequest *request = response.notification.request;     NSString *requestIdentifier = request.identifier; if (requestIdentifier == nil)     { return; }   [database selectModelFromId:requestIdentifier withCompletionHandler:^(MyModel *modelObj,                                                                                     NSError *errorOrNil)     { if (modelObj != nil) { [self makeWebViewControllerForModeAndPutOnScreen:modelObj]; } else { NSLog(@"error loading data for notification..."); } }]; } Okay so the view controller loaded uses WKWebView to load web content. Again every once in awhile the app crashes when I tap a notification. No crash report is ever generated for my app. I don't know why this is happening. Anybody experience anything similar and know what the issue could be? Thanks in advance.
0
0
470
Nov ’21
Testing Sign Out Events with CloudKit?
I'd like to test how my app behaves when the user signs out of iCloud and my app is in memory. In the iOS Simulator, the "Sign Out" button for iCloud is grayed out so I can't use the simulator to test. I'm hesitant to use a real device tied to my Apple ID because signing out of iCloud System wide has side effects with many apps and I don't want to potentially lose any data. However, I did test on a real device by going the Settings app -> iCloud and disabled iCloud only for my app. When I do this, the system terminates my app and does not post a CKAccountChangedNotification. I only tested turning off the iCloud switch for my app. Does the system simply terminate apps when the user logs out of iCloud system wide too? In what cases is the CKAccountChangedNotification posted? Detecting sign out by listening for CKAccountChangedNotification would seem to be pointless if apps are terminated when the user signs out of iCloud.
0
0
364
Jun ’22
Resize UITargetedPreview as part of custom animation?
I'd like to resize a UITargetedPreview as part of a custom animation. I tried doing this by using the animator provided in: - (void)tableView:(UITableView *)tableView willDisplayContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(nullable id<UIContextMenuInteractionCommitAnimating>)animator But resizing the source view for the target preview does not cause the container view to resize with it (leaving a large gap after my custom animation completes). So my preview is wrapped in a visual effects view that doesn't downsize with UITargetedPreview's view I provided. I also tried wrapping a snapshot view in a UIViewController and using previewProvider block instead of using a UITargetPreview. I am able to resize the previewViewController by setting the preferredContentSize property and resizing works, but it still doesn't look right because the default animation for the preview view controller breaks with the custom animation I'm trying to implement. Anyone know if this is possible?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
390
Sep ’22
presentedViewController Not set to nil on iOS 16 after dismissal. Calls to -presentViewController:animated:completion: then fail.
Testing my app, I noticed a button in my UI which presents a UIAlertController appeared to do nothing all of a sudden, after a few days. So hooking up the console app I see UIKit spit out the following log when I press the button: "Warning: Attempt to present UIAlertController on MyViewController which is already presenting SomeOtherViewController. No view controller appears to be presented. SomeOtherViewController is not currently in the UI but for some reason after it was dismissed the presentedViewController property wasn't set to nil (haven't been able to reproduce the issue yet). So SomeOtherViewController I know is a "Detail View Controller" which only get pushed on the UINavigationController stack (I never present it modally). The only time it gets presented modally is when it is a "preview view controller" used in UIContextMenuConfiguration, but otherwise it doesn't get presented. Has anyone run into this sort of situation before and know of a potential cause/solution? The presentedViewController does not appear on screen but for some reason UIKit is holding a strong reference to it in the presentedViewController property which prevents subsequent calls to -presentViewController:animated:completion: As a workaround I could try using the code below but I'd really like to find the root cause of the issue: -(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {     UIViewController *currentPresentedVC = self.presentedViewController;     if ([currentPresentedVC isKindOfClass:[SomeOtherViewController class]])     {        //this is unexpected.         [currentPresentedVC dismissViewControllerAnimated:NO completion:^{             [super presentViewController:viewControllerToPresent animated:flag completion:completion];         }];     }     else     {         [super presentViewController:viewControllerToPresent animated:flag completion:completion];     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
1.4k
Sep ’22
Mac Catalyst When to Handle Setting Min/Max Size for UISplitViewController columns? Window Resize Event?
Trying to use UISplitViewController. Since this app can be run on many different monitor sizes I want to allow the splits to be resized reasonably. There is this API: //Allow setting the primary column width with point values. This is especially useful in Catalyst where the window may be resized more often. // If set to non-Automatic, takes precedence over preferredPrimaryColumnWidthFraction. @property(nonatomic, assign) CGFloat preferredPrimaryColumnWidth API_AVAILABLE(ios(14.0)); // default: UISplitViewControllerAutomaticDimension > > @property(nonatomic, assign) CGFloat minimumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); @property(nonatomic, assign) CGFloat maximumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); // An animatable property that can be used to adjust the minimum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat minimumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: UISplitViewControllerAutomaticDimension // An animatable property that can be used to adjust the maximum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat maximumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: At what point in time should I be changing the preferredPrimaryColumnWidth, the min/and max width values? What event? If I was in Appkit I could maybe use something like NSWindowDidResizeNotification, then compute min/max sizes for each column based off the current window size (but I think NSSplitView gives the delegate an opportunity to control constraining column sizes if I remember correctly so I don't think that it would necessary to listen for a window resize event). I find the default sizes set by UISplitViewController to be insufficient (I want to allow users to size columns wider). Ideally this would be easier if there was minimumPrimaryColumnFraction and maxPrimaryColumnFraction. Then I just set the min/max fractions once to reasonable values and not worry about changing them on window resize. But since we can only set min/max with a hardcoded point size it seems more complicated?
0
1
523
Oct ’22
Disable vibrancy on titlebar/toolbar area of window on Mac Catalyst?
I can't seem to get rid of the "vibrancy" effect on the titlebar/toolbar area of the window on Mac Catalyst. I have a triple Split View controller. The primary vc style is sidebar in the split vc.. And that has the blur/visual effect and that's all well and good. But the title bar area on the supplementary column has the blur effect too and it looks kind of terrible (the navigation bar in the supplementary view controller has all of its navigationBar appearances configured with opaque content:   UINavigationBarAppearance *opaqueAppearance = [[UINavigationBarAppearance alloc]init];     [opaqueAppearance configureWithOpaqueBackground];     opaqueAppearance.backgroundEffect = nil;     opaqueAppearance.backgroundColor = [UIColor myColor]; //set to all appearances But I still get the blur effect on the navigation bar, which presumably is being mapped to NSToolbar. Is it possible to disable this blur effect for the column? It really doesn't look good in my app.
0
0
616
Oct ’22
Mac Catalyst: How to make a "Done" button that invokes its action when the return key is pressed?
On macOS it is typical for apps to have a "Done" button showing at the bottom of a window sheet. Usually the button is blue (or whatever your system accent color is set to) and this button can be invoked by pressing the return key. On NSButton all you do is assign the return key as the key equivalent. So in the Mac Catalyst environment how do I achieve this behavior? I'm able to get the button to look exactly how I want configuring UIButton like this: UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeSystem]; [doneButton setTitle:@"Done" forState:UIControlStateNormal]; doneButton.role = UIButtonRolePrimary; Is there a quick way to get its action to be invoked when the return key is pressed or do I have to manually implement UIKeyCommand? Thanks in advance to anyone who answers.
0
0
630
Nov ’22
Mac Catalyst Stop UITableView from Discarding Selection When a Row is Swiped?
I have a UITableView that supports multiple selection on Mac. My table view also supports swipe actions. When a row is selected and I swipe on another table view row to expose swipe actions, UITableView discards the current selection for seemingly no reason. To reproduce: Configure a UITableView that allows multiple selection. Configure swipe actions. Run the app. Select a couple rows (via Command click or shift click). Two finger drag on the track pad to expose a swipe action on another row. Swipe to hide the swipe actions (not invoking an action). UITableView discards the entire selection for no apparent reason. Also the UITableView discards the selection without even informing the delegate (I have a label displaying the selection count in the UI and it still shows the selection count before UITableView clears the selection when a row is swiped). I don't want to discard the selection just because a swipe action is exposed. I tried working around the problem by reselecting the rows index paths in -tableView:didEndEditingRowAtIndexPath: -(void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(nullable NSIndexPath*)indexPath { //Swipe action is over..fix the selection: [self reselectIndexPathsAtTheEndOfSwipeActionEditing]; / } But when one of the selected index paths is outside the visible region of the table view scroll position jumps after programmatically reselecting the rows which looks wrong... Anyone have a workaround for this?
0
0
837
Dec ’22
Mac Catalyst UITableView swipe actions sometimes don't work (either getting swallowed by the two finger drag gesture to open the Notification Center or something else)
I have a UITableView in the supplementary column of a UISplitViewController. Every so often trackpad gestures to reveal swipe actions stop working. I believe the gesture may be getting swallowed by the two finger drag to open the Notification Center but I can't be sure, maybe there's another gesture swallowing it. I keep sliding my fingers to reveal the swipe action with no luck. Eventually swipe actions start working again but it really wouldn't be acceptable for me to ship an app this way. Anyone else have issues with the swipe gestures on UITableView not working properly? Advice/workarounds are welcomed.
0
0
535
Dec ’22
Mac Catalyst NSToolbar / Title Bar Doesn't Honor overrideUserInterfaceStyle value of the UIWindow
It is normal to have a preference like: “Always use Dark Mode” in an app to allow the user to opt in to Dark mode in the current app without turning it on System wide. On iOS you can manage this by detecting the change in the app preference and when it is turned on you set the overrideUserInterfaceStyle property on the UIWindow to UIUserInterfaceStyleDark. On Mac Catalyst however this does not work. If you set the overrideUserInterfaceStyle property to UIUserInterfaceStyleDark the NSWindow underneath doesn’t update to reflect dark mode. The titlebar doesn’t update for dark mode either. And neither does the NSToolbar. Only UIViewControllers inside the UIWindow reflect the overrideUserInterfaceStyle Ideally it would be great if there was a overrideUserInterfaceStyle property on UIApplication but there is not. Is there a way to force the NSWindow/NSToolbar created by Mac Catalyst to use a particular appearance (without an Appkit bundle)?
0
1
610
Jan ’23
Mac Catalyst: Mac Specific Data Assets Don't Load from Asset Catalog via NSDataAsset
My configuration: A iOS app that supports Mac Catalyst. This Mac Catalyst app is “optimized for Mac” it is not scaled to match iPad. I open the asset catalog and add a “Data Asset” which is a .txt file. This is set to “Universal.” I add “Mac” variant for this data asset and I add a .txt with different text. I load the string at runtime like this: NSDataAsset *scriptData = [[NSDataAsset alloc]initWithName:@"TextDataAsset"]; NSString *loadedText = [[NSString alloc]initWithData:scriptData.data encoding:NSUTF8StringEncoding]; When I run that on Mac Catalyst the text loadedText is an empty string, which is wrong. Running on iOS I get the expected string. Is this the intended behavior? Am I supposed to use the "iPad" device for Mac assets (because I don't believe that is the case with images, etc.) In any case I filed FB12005255
0
0
606
Feb ’23
WKWebView Mac Catalyst Text Selection Issues?
I notice on some pages to be having text selection issues on Mac Catalyst. AppKit WKWebview appears to work better. Is there a workaround? Related: https://stackoverflow.com/questions/74959180/how-to-use-appkit-wkwebview-in-a-mac-catalyst-app https://stackoverflow.com/questions/61215569/macos-maccatalyst-wkwebview-text-selection-behavior Would be great if Mac Catalyst just got the normal Mac WKWebView but there appears to be differences.
0
0
715
Feb ’23
Mac Catalyst: UISearchController with UITableView Randomly Moves the Scroll Position after Swipe Action
I have a UISearchController. It uses a search results controller (the search results controller uses a UITableView). If I select a row.. scroll a bit, deactivate the window then reactivate the window the scroll position starts flying. Usually this random scroll exposes the selected row but sometimes it scroll elsewhere. I subclassed UITableView to try to figure out what's causing this random scrolling. I have a breakpoint in -scrollRectToVisible:scrollRectToVisible: -(void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated {     [super scrollRectToVisible:rect animated:animated]; //<--Break point here } And was able to determine that its coming from UIFocusSystem/UISearchController: #1 0x00000001d65d748c in -[UISearchController _willUpdateFocusInContext:withAnimationCoordinator:] () #2 0x00000001d611fdd0 in __85-[UIFocusSystem _sendWillUpdateFocusNotificationsInContext:withAnimationCoordinator:]_block_invoke () #3 0x00000001d60d4944 in _UIFocusEnvironmentEnumerateAncestorEnvironments () #4 0x00000001d6120480 in -[UIFocusSystem _sendNotificationsForFocusUpdateInContext:withAnimationCoordinator:usingBlock:] () #5 0x00000001d611faf8 in -[UIFocusSystem _sendWillUpdateFocusNotificationsInContext:withAnimationCoordinator:] () #6 0x00000001d611f42c in -[UIFocusSystem _updateFocusWithContext:report:] () #7 0x00000001d611b90c in -[UIFocusSystem _setEnabled:withAnimationCoordinator:] () #8 0x00000001d61a1128 in __49-[_UIFocusSystemSceneComponent _setupFocusSystem]_block_invoke () #9 0x00000001d618ccac in -[_UIFocusStateObserver notifyObserversIfNecessary] () -- Workarounds/input always appreciated.
0
0
486
Mar ’23